package com.yygo.model;

import com.yygo.Constants;
import com.yygo.model.enums.TransferType;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by tiansha on 2015/11/7.
 */
@Entity
@Table(name = "money_transfer_record")
public class MoneyTransferRecord {

    private Long id;

    private LoanRequest loanRequest;

    private float amount;
    private String auditOperator;
    private String transferOperator;
    private Date generateDate;
    private Date transferDate;

    private String status = Constants.STATUS_PENDING;

    private String bank;
    private String bankAccount;
    private String cardName;

    private String serialNo;

    private String memo;

    private TransferType type;
    private BondCompany bondCompany;

    private List<RepayRecord> repayRecords = new ArrayList<>();

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @OneToOne
    @JoinColumn(name="req_id")
    public LoanRequest getLoanRequest() {
        return loanRequest;
    }

    public void setLoanRequest(LoanRequest loanRequest) {
        this.loanRequest = loanRequest;
    }

    @Column(name="amount")
    public float getAmount() {
        return amount;
    }

    public void setAmount(float amount) {
        this.amount = amount;
    }

    @Column(name="audit_operator")
    public String getAuditOperator() {
        return auditOperator;
    }

    public void setAuditOperator(String auditOperator) {
        this.auditOperator = auditOperator;
    }

    @Column(name="transfer_operator")
    public String getTransferOperator() {
        return transferOperator;
    }

    public void setTransferOperator(String transferOperator) {
        this.transferOperator = transferOperator;
    }

    @Column(name="generate_date")
    public Date getGenerateDate() {
        return generateDate;
    }

    public void setGenerateDate(Date generateDate) {
        this.generateDate = generateDate;
    }

    @Column(name="transfer_date")
    public Date getTransferDate() {
        return transferDate;
    }

    public void setTransferDate(Date transferDate) {
        this.transferDate = transferDate;
    }

    @Column(name="status")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Column(name="bank")
    public String getBank() {
        return bank;
    }

    public void setBank(String bank) {
        this.bank = bank;
    }

    @Column(name="bank_account")
    public String getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(String bankAccount) {
        this.bankAccount = bankAccount;
    }

    @Column(name="card_name")
    public String getCardName() {
        return cardName;
    }

    public void setCardName(String cardName) {
        this.cardName = cardName;
    }

    @Column(name="serial_no")
    public String getSerialNo() {
        return serialNo;
    }

    public void setSerialNo(String serialNo) {
        this.serialNo = serialNo;
    }

    @Column(name="memo")
    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "type", length = 20)
    public TransferType getType() {
        return type;
    }

    public void setType(TransferType type) {
        this.type = type;
    }

    @ManyToOne
    @JoinColumn(name="bond_id")
    public BondCompany getBondCompany() {
        return bondCompany;
    }

    public void setBondCompany(BondCompany bondCompany) {
        this.bondCompany = bondCompany;
    }

    @OneToMany(mappedBy = "moneyTransferRecord", cascade = CascadeType.ALL)
    public List<RepayRecord> getRepayRecords() {
        return repayRecords;
    }

    public void setRepayRecords(List<RepayRecord> repayRecords) {
        this.repayRecords = repayRecords;
    }
}
